package Demo4;

import java.util.Scanner;

class Array {
	String name;
	int run_time;

	public Array(String name, int run_time) {
		this.name = name;
		this.run_time = run_time;
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int time = s.nextInt();
		int len = s.nextInt();
		Array[] array = new Array[len];
		for (int i = 0; i < len; i++) {
			String name = s.next();
			int run_time = s.nextInt();
			array[i] = new Array(name, run_time);
		}
		int time_round = s.nextInt();
		System.out.println(running(time, len, array, time_round));
	}

	//写一个函数返回输入的时间片轮转次数返回正在工作的进程名
	//time 时间片大小 time_round时间片轮转次数
	public static String running(int time, int len, Array[] array, int time_round) {
		int nofinish = len, i = 0;
		int count = 0;
		String value = "";
		while (nofinish > 0) {
			if(array[i].run_time > 0) {
				array[i].run_time -= time;
				count++;
			} else {
				i++;
				if(i>=len) i=0;
				continue;
			}
			if (array[i].run_time <= 0) {
				nofinish--;
			}
			//如果当前轮转次数=时间片次数
			if (count == time_round) {
				value = array[i].name;
				break;
			}
			i++;
			if(i>=len) i=0;
		}
		return count == time_round?value:"over";
	}
}
